#include <iostream>
#include "udpServer.hpp"
#include <memory>
#include "MessageRoute.hpp"
using namespace std;
//using namespace Dict_ns;
//./udpserver ip port
void Usage(string proc)
{
    cout << "Usage:./udpServer server-ip server-port" << endl;
}
int main(int argc, char *argv[])
{
    if (argc != 2)
    {
        Usage(argv[0]);
        exit(-1);
    }
    //消息转发
    MessageRoute route;

    // 构建服务器对象
    string ip = /*argv[1]*/ "0.0.0.0"; // ip地址
    uint16_t port = stoi(argv[1]);     // 端口号
    // 利用回调，将翻译功能与服务器绑定，但不将Dict字典类与服务强耦合
    unique_ptr<UdpServer> usvr = make_unique<UdpServer>(/*ip, */ port, bind(&MessageRoute::Route, &route, placeholders::_1, placeholders::_2,placeholders::_3));
    usvr->InitServer(); // 初始化服务器
    usvr->Start();      // 启动服务器端

    return 0;
}